package collectionFrame.Demo7_LinkedListExample;

import java.util.HashSet;
import java.util.Set;

public class RepeatNum {

    public boolean hasRepeatNum(int[] nums){

        boolean b = true;

        Set<Integer> numSet = new HashSet<>();

        for (int num : nums) {
            //set中的add方法，如果是重复数据，返回值为false
            b = numSet.add(num);
            if(!b){
                break;
            }
        }

        return !b;
    }

    public static void main(String[] args) {
        System.out.println(new RepeatNum().hasRepeatNum(new int[]{1,2,3,4,2,5}));
    }

}
